<template>
	<div>
		
		<el-row :gutter="10">
		  <el-col :span="5"><el-input  v-model="search.levelName" placeholder="请输入要护理级别"></el-input></el-col>
		  <el-col :span="6">
		    <el-button type="primary" icon="el-icon-search" @click="searchData()">搜索</el-button>
		    <el-button type="primary" icon="el-icon-circle-plus-outline"  plain @click="add()" >添加</el-button>
		  </el-col>
		</el-row>
		<el-table :data="result.tableData" style="width: 100%">
			<el-table-column label="序号" prop="id" width="100px"></el-table-column>

			<el-table-column label="护理级别" prop="levelName" width="150px"></el-table-column>

			<el-table-column label="状态" prop="levelStatus" width="150px"></el-table-column>
			<el-table-column label="操作">
				<template slot-scope="scope">
					<el-button size="mini"  @click="handleEdit(scope.row.id)">编辑</el-button>
					<el-button size="mini" type="danger" @click="handleDelete(scope.row.id)">删除</el-button>
					<el-button  size="mini" type="success" @click="handleConfigure">护理内容配置</el-button>
				</template>
			</el-table-column>
		</el-table>
		
		<el-pagination style="margin-top:20px;" background layout="prev, pager, next"
				 :total="result.total"
				 :current-page.sync="query.current" :page-size="query.size" @current-change="getData()">
		</el-pagination>
		
		<el-dialog :title="title" :visible.sync="show">
			
			<nurselevelAdd :show.sync="show" @getData="getData" :editid="editid" :key="showNum"></nurselevelAdd>
			
		</el-dialog>
	</div>
</template>
<script>
import axios from '@/utils/axiosutils.js';
import nurselevelAdd from './nurselevel_add.vue';
export default {
	data() {
		return {
			search: {
			  levelName: ''
			},
			query: {
			  levelName: '',
			  current: 1,
			  size: 10
			},
			result:{
			  tableData: [],
			  pages: 0
			},
			showNum: 0,
			show: false,
			editid: null,
			title: ''
		};
	},
	components:{
	  nurselevelAdd
	},
	created() {
		this.getData();
	},
	methods: {
		getData() {
			axios.get(
				'/nurseLevel/list',
				resp => {
					console.log(resp);
					let page = resp.obj;
					this.result.tableData = page.records
					this.result.total = page.total;
				},
				this.query
			);
		},
		searchData() {
		  this.query.levelName = this.search.levelName
		  this.query.current = 1
		  this.getData()
		},
		add(){
		  this.showNum++;
		  this.title = '添加护理级别'
		  this.editid = null
		  this.show = true
		},
		handleEdit(id) {
		this.showNum++;
		  this.title = '修改护理级别'
		  this.editid = id
		  this.show = true
		},
		handleDelete(id) {
		      axios.del('/nurseLevel/del',response => {
		        this.getData()	
		      },{ id: id })
		},
		handleConfigure(){
			axios.get(
				'/nurseLevelContent/list',
				resp => {
					console.log(resp);
					this.$router.push('/nurselevelcontent');
				},
				this.query
			);
		}
	}
};
</script>

<style>
	.el-row{
		height: 50px;
	}
.el-main {
	background-color: #e9eef3;
	color: #333;
	line-height: 20px !important;
}
</style>
